<html>
<head>
  <title>test Ws mqtt.js</title>
</head>
<body>
<script src="./browserMqtt.js"></script>
<script>
	var options = {
	    host: "broker.mqttdashboard.com",
	    port: 8000
	  };
      var client = mqtt.connect('ws://10.0.1.68:1884', {clientId: 'shansjlinshansj'}); // you add a ws:// url here
      client.subscribe("mqtt/demo");

      client.on("message", function(topic, payload) {
        // alert([topic, payload].join(": "));
        // client.end();
        console.log('topic:' + topic + ',payload:' + payload);
      });

      setInterval("myInterval()",1000);//1000为1秒钟
       function myInterval()
       {
       		client.publish("mqtt/demo", "hello world!");
       }

      
    </script>
</body>
</html>